<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<h1>jsonp跨域问题</h1>
<button>解决跨域问题</button>
<script>

  function callback(data) {
    console.log('真正执行',data)
  }


  const btn = document.querySelector('button')
  let oScript = null
  btn.onclick = function (){

    if (oScript){
      oScript.remove()
    }
    oScript = document.createElement('script')
    oScript.src = 'http://127.0.0.1:8090/JsonPGet?userId=001&name=wdh&cb=callback'
    document.body.appendChild(oScript)
  }
</script>

<!--JsonP解决跨域问题的原理-->
<!--<script src="http://127.0.0.1:8090/JsonPGet"></script>-->
</body>
</html>